<template>
    <div>
        <el-form>
          <el-form-item label="用户名">
              <el-input v-model="mobile" placeholder="请输入用户民"></el-input>
          </el-form-item>
          <el-form-item label="密码">
              <el-input v-model="password" placeholder="请输入密码"></el-input>
          </el-form-item>
          <el-button type="login" @click="logines">登录</el-button>
        </el-form>
        <el-button type="register" @click="jump">注册</el-button>
    </div>
</template>

<script>
import Axios from 'axios'
import qs from 'qs'
export default {
    name: "Goods_Login",
    data(){
        return{
            mobile:null,
            password:null,
        }
    },
    methods:{
        logines(){
            Axios.post("http://127.0.0.1:8000/shop/login/", 
            qs.stringify({nickname:this.nickname, password: this.password}))
            .then(resp=>{
                console.log(">>>>>>>>>>>>>>>>>>", resp)
                if(resp.data.code === 200){
                    console.log("登录成功", resp)
                    this.$router.push({name:"Business_Management", params: {user_id:resp.data.id}})
                }
            }).catch(err=>{
                console.log("登陆失败", err)
            })
        },
        jump(){
            this.$router.push("/goods_register")
        }
    }
}
</script>

<style>
.el-button{
    width: 50%;
    margin-top: 20px;
    height: 40px;
    background-color: rgb(228, 247, 247);
}
.el-input{
    border-width: 50%;
    width: 100%;

}
</style>